package com.itheima.mapper;

import com.itheima.pojo.Student;
import com.itheima.pojo.StudentData;
import com.itheima.pojo.StudentQueryParam;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface StudentMapper {
    List<Student> pageQuery(StudentQueryParam studentQueryParam);

    int insert(Student student);

    Student selectById(Integer id);

    int update(Student student);

    void deleteByIds(List<Integer> id);

    List<StudentData> selectStudentCountData();

    @MapKey("clazzName")
    List<Map> countStudentDegreeData();

    @Select("select count(*) from student where clazz_id=#{clazzId} limit 1")
    Integer existsWithClazzId(Integer clazzId);

    @Update("update student set violation_count=violation_count+1, violation_score=violation_score+#{score} where id=#{id}")
    Integer updateViolation(@Param("id") Integer id, @Param("score") Integer score);

}
